import store from '@/store'
export default {
  inserted: function(el, binding) {
    const { value } = binding
    const roleCodes = store.getters.roleCodes
    if (value && value instanceof Array && value.length > 0) {
      const hasPermission = roleCodes.some(role => {
        return value.includes(role)
      })
      if (!hasPermission) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error(`权限指令参数有误`)
    }
  }
}
